﻿namespace HRM.CORE.Workdesk.Chart
{
    using DevExpress.XtraCharts.Printing;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using HRM.CORE;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms; using Common;

    public class xucChartRate : xucChartBase
    {
        private IContainer components;
        private LabelControl labelControl1;
        private LabelControl labelControl2;
        private TimeEdit teFromYear;
        private TimeEdit teToYear;

        public xucChartRate()
        {
            DateTime now;
            this.components = null;
            this.InitializeComponent();
            try
            {
                now = new DateTime(DateTime.Now.Year - 3, DateTime.Now.Month, DateTime.Now.Day);
            }
            catch
            {
                now = DateTime.Now;
            }
            this.teFromYear.Time = now;
            this.teToYear.Time = DateTime.Now;
            this.teFromYear.EditValueChanged += new EventHandler(this.teFromYear_EditValueChanged);
            this.teToYear.EditValueChanged += new EventHandler(this.teToYear_EditValueChanged);
            base.m_NameChart = "Tỷ Lệ Số Lao Động";
            base.m_Type = 0;
            this.ReloadData();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.teFromYear = new TimeEdit();
            this.teToYear = new TimeEdit();
            this.labelControl1 = new LabelControl();
            this.labelControl2 = new LabelControl();
            base.m_DataChart.BeginInit();
            base.panelControl8.BeginInit();
            base.panelControl8.SuspendLayout();
            base.chart.BeginInit();
            this.teFromYear.Properties.BeginInit();
            this.teToYear.Properties.BeginInit();
            base.SuspendLayout();
            base.panelControl8.Controls.Add(this.teToYear);
            base.panelControl8.Controls.Add(this.labelControl1);
            base.panelControl8.Controls.Add(this.teFromYear);
            base.panelControl8.Controls.Add(this.labelControl2);
            base.panelControl8.Controls.SetChildIndex(this.labelControl2, 0);
            base.panelControl8.Controls.SetChildIndex(base.lbPie, 0);
            base.panelControl8.Controls.SetChildIndex(this.teFromYear, 0);
            base.panelControl8.Controls.SetChildIndex(base.lbBar, 0);
            base.panelControl8.Controls.SetChildIndex(this.labelControl1, 0);
            base.panelControl8.Controls.SetChildIndex(base.lbPrint, 0);
            base.panelControl8.Controls.SetChildIndex(this.teToYear, 0);
            base.panelControl8.Controls.SetChildIndex(base.lbExport, 0);
            base.lbBar.Location = new Point(0x1d3, 3);
            base.lbBar.Size = new Size(0, 0x10);
            base.lbBar.TabStop = false;
            base.lbBar.Text = "";
            base.lbPie.Location = new Point(0x211, 4);
            base.lbPie.Size = new Size(0, 0x10);
            base.lbPie.TabStop = false;
            base.lbPie.Text = "";
            base.lbPrint.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            base.lbPrint.Location = new Point(0x211, 5);
            base.chart.BorderOptions.Color = Color.Transparent;
            base.chart.BorderOptions.Visible = false;
            base.chart.OptionsPrint.SizeMode = PrintSizeMode.Zoom;
            base.lbExport.Size = new Size(0, 13);
            base.lbExport.TabStop = false;
            base.lbExport.Text = "";
            this.teFromYear.EditValue = new DateTime(0x7db, 9, 7, 0, 0, 0, 0);
            this.teFromYear.Location = new Point(50, 2);
            this.teFromYear.Name = "teFromYear";
            this.teFromYear.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.teFromYear.Properties.Mask.EditMask = "yyyy";
            this.teFromYear.Size = new Size(0x33, 20);
            this.teFromYear.TabIndex = 7;
            this.teToYear.EditValue = new DateTime(0x7db, 9, 7, 0, 0, 0, 0);
            this.teToYear.Location = new Point(160, 2);
            this.teToYear.Name = "teToYear";
            this.teToYear.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.teToYear.Properties.Mask.EditMask = "yyyy";
            this.teToYear.Size = new Size(0x33, 20);
            this.teToYear.TabIndex = 8;
            this.labelControl1.Appearance.BackColor = Color.Transparent;
            this.labelControl1.Appearance.Options.UseBackColor = true;
            this.labelControl1.Location = new Point(4, 5);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(40, 13);
            this.labelControl1.TabIndex = 9;
            this.labelControl1.Text = "Từ năm:";
            this.labelControl2.Appearance.BackColor = Color.Transparent;
            this.labelControl2.Appearance.Options.UseBackColor = true;
            this.labelControl2.Location = new Point(0x6b, 5);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new Size(0x2f, 13);
            this.labelControl2.TabIndex = 10;
            this.labelControl2.Text = "Đến năm:";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Name = "xucChartRate";
            base.m_DataChart.EndInit();
            base.panelControl8.EndInit();
            base.panelControl8.ResumeLayout(false);
            base.panelControl8.PerformLayout();
            base.chart.EndInit();
            this.teFromYear.Properties.EndInit();
            this.teToYear.Properties.EndInit();
            base.ResumeLayout(false);
        }

        protected override void ReloadData()
        {
            base.ReloadData();
            base.m_DataChart = new HRM_EMPLOYEE().GetRate(MyLogin.Level, MyLogin.Code, int.Parse(this.teFromYear.Text), int.Parse(this.teToYear.Text));
            base.LoadChart(base.m_Type, base.m_DataChart);
        }

        private void teFromYear_EditValueChanged(object sender, EventArgs e)
        {
            this.ReloadData();
        }

        private void teToYear_EditValueChanged(object sender, EventArgs e)
        {
            this.ReloadData();
        }
    }
}

